Powershell remoting exchange server 2007
Hi,
I am trying to connect to exchange server2007 remotely and execute the exchange commands
I am getting the following error
The WinRM client sent a request to an HTTP server and got a response saying the requested HTTP URL was not available. This is usually returned by a HTTP server that does not support the WS-Management protocol.
I tried different uri but not succeeded. Below is my code snippet :
string sSHELL_URI = "http://schemas.microsoft.com/powershell/Microsoft.PowerShell";
Uri objCompURI = new Uri(String.Format("http://{0}:5985/wsman", m_sServerName));
WSManConnectionInfo connectionInfo = new WSManConnectionInfo(m_objServerUri, m_SHELL_URI, m_objCreds);
connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Kerberos;
RunspacePool remoteRunspacePool = RunspaceFactory.CreateRunspacePool(1, 2, connectionInfo));
remoteRunspacePool.Open();
PowerShell objps = PowerShell.Create();
objps.AddScript(sScript);
objps.RunspacePool = remoteRunspacePool;
Collection<PSObject> results = objps.Invoke();
Thanks in Advance
Viswanath B
January 12th, 2011 6:17am
Hi,
This is IIS related issue. Follow the kb article for 2010. It may work for 2007 also:
http://support.microsoft.com/kb/2027062Regards from www.windowsadmin.info
Free Windows Admin Tool Kit Click here and download it now
January 12th, 2011 7:23am
Hi Philip,
I checked the configuration. It is same as mentioned in the article. But still I am getting the same error on Server1.
On server 2 I am getting below error.
Connecting to remote server failed with the following error message : The WinRM client received an HTTP status code of 403 from the remote WS-Management service.
Thanks,
Viswanath
January 12th, 2011 8:08am
Try the following
On the Exchange Server 2010 Client Access server, open IIS Manager.
Locate the PowerShell Virtual directory under Default Web Site, and then click SSL Settings in the details pane.
Double-click SSL Settings and then clear the Require SSL option.
In the details pane, click Apply to save the settings in IIS Manager.
Restart IIS. Best Rgds, Ashish | Unified Comunication | MCTS | MCITP | Please remember to select option "Propose As Answer" if solution work for you | My posts hold no assurances, no promises, and they measured no rights.
Free Windows Admin Tool Kit Click here and download it now
January 12th, 2011 9:58am
Ashish,
Thanks for the reply. I am using Exchange 2007. in 2007 I don't see any Powershell VD in IIS.
January 12th, 2011 12:30pm
the following solution worked for few people:
1. make sure IIS WinRM extension is installed
2. open powershell and run command : WinRM Quickconfig
3. Open IIS go to Powershell virtual directory and check that SSL in disabled and authentification is set only to Anonymous
4. Open Windows powershell modules
5. run Remove-PowershellVirtualDirectory command
6. run New-PowershellVirtuallirectory command
7. IISreset
Connecting to remote server failed with the following error message:
The WinRM client received an HTTP status code of 403 from the remote WS-Management service.
Possible Causes:
1. The "Require SSL" option has been enabled on the PowerShell Virtual Directory. To resolve this, remove the "Require SSL" option from this Virtual Directory. The Exchange Management Tools connect over port 80, not 443, so
if Require SSL is set, when a connection is attempted on port 80, IIS will return a 403 error indicating SSL is required.
Article ID :
http://msexchangeteam.com/archive/2010/02/04/453946.aspx will give other related issues listBest Rgds, Ashish | Unified Comunication | MCTS | MCITP | Please remember to select option "Propose As Answer" if solution work for you | My posts hold no assurances, no promises, and they measured no rights.
January 13th, 2011 9:25am
Hi Ashish,
New-PowershellVirtualdirectory cmdlet doesn't work on exchange 2007. It is in specific to exchange 2010. I don't have any issues with exchange 2010. My code is working fine for 2010. Problem is only with powershell remoting to 2007.
Thanks,
Viswanath B
Free Windows Admin Tool Kit Click here and download it now
January 17th, 2011 1:25am
Remote Power Shell is the feature added in E2K10. So it will not work in Exchange 2007.
But interesting thing I found in the below mentioned blog..
Exchange 2007 Sp2 - Powershell 2.0 Remoting
http://social.technet.microsoft.com/Forums/en/exchangesvrgeneral/thread/4596035a-cede-4541-8b8e-e2e9bf1b40dc
Check if you have all the Pre-Req.
One thing I'm sure id WinRM is the featue of Exchange 2010. Not sure if it can be achived in Exchange 2007.
January 18th, 2011 3:42am
See
With Exchange 2007 you have to execute the cmdlets locally on the machine where the code is running from that means that machine needs to exist is a security context that will allow you run the Exchange Management Shell eg installed as per
http://technet.microsoft.com/en-us/library/bb232090%28EXCHG.80%29.aspx. If there is no Trust between the domains your machine is in and Exchange Server and you can't logon onto the machine where the code is running with
a user that has been deletegated Exchange Administration rights then your code wont work with 2007 because there is no ability to specify alternate credentials in the EMS. You need to have the code running from a machine where the secruity context is availible.
Another option if this isn't possible for you is that the log files themselves are plain text so you can parse the directly eg using something like Logparser the problem is that these files can be very large so its not something unless your log
files are small that you want to attempt over a network.
By
Pah Finder
Free Windows Admin Tool Kit Click here and download it now
January 22nd, 2011 12:33am